﻿using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ComUIControl
{
    public partial class FormWaitting : MetroForm
    {
        private int x0 = 0;
        private int y0 = 0;

        public FormWaitting()
        {
            InitializeComponent();
            this.ControlBox = false;   // 设置不出现关闭按钮
            x0 = labelWaitInfo.Location.X;
            y0 = labelWaitInfo.Location.Y;
        }

        private delegate void SetTipHandler(string text);
        public void SetTip(string text)
        {
            if (this.labelWaitInfo.InvokeRequired)
            {
                this.BeginInvoke(new SetTipHandler(SetTip), text);
            }
            else
            {
                this.labelWaitInfo.Text = text;
            }
        }
        public void ReLayout()
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Action(ReLayout));
            }
            int x = (this.Width - labelWaitInfo.Width) / 2;
            labelWaitInfo.Location = new Point(x, y0);
        } 

        private void FormWaitting_Load(object sender, EventArgs e)
        {
            ReLayout();         
        }
    }
}
